package com.mengtian_tech.tju.dataquery.api.service;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;

import com.mengtian_tech.tju.dataquery.api.model.tjuOracle.College;


@Service
public class StudentService {
	

	@Autowired
	@Qualifier("jdbcTemplateThimis")
	JdbcTemplate jdbcTemplateThimis;
	
	
	public College getCollege(String studentId) {
	
		List<Map<String,Object>> list = this.jdbcTemplateThimis.queryForList(
				"select t1.college_id,t3.college from "
				+ "app_manager.dict_major_list t1,app_manager.student t2 ,app_manager.dict_college t3  where t2.student_id=? and t2.major_id = t1.major_id  and t3.college_id = t1.college_id",
				studentId);
		
		if(list.size() > 0) {
			Map<String, Object> map  = list.get(0);
			College college = new College();
			college.setCollegeId(map.get("college_id").toString());
			college.setCollegeName(map.get("college").toString());
			return college;
		}
		
		return null;
	}
}
